package geometry;

import java.awt.Point;

public class Geometry {
	
	public static Point rot(double angulo,Point p){
		if(angulo == 0)
			return p;
		else{
			int x = Math.round((float)(p.getX()*Math.cos(angulo) + p.getY()*Math.sin(angulo)));
			int y = Math.round((float)(-p.getX()*Math.sin(angulo) + p.getY()*Math.cos(angulo)));
			return new Point(x,y);
		}
	}
	
	public static Point polar(double r,double angulo){
		return rot(Math.round(angulo),new Point((int)r,0));
	}
	
	public static Point smult(double f,Point p){
		if(f==1)
			return p;
		else
			return new Point(Math.round((float)(f*p.getX())),Math.round((float)(f*p.getY())));
		
	}
	
	public static Point add(Point p1,Point p2){
		return new Point((int)(p1.getX()+p2.getX()),(int)(p1.getY()+p2.getY()));
	}
	
	public static double len(Point p){
		return Math.sqrt(Math.pow(p.getX(),2) + Math.pow(p.getY(),2));
	}
	
	

}
